import QtQuick 2.0
import QtQuick.Controls 2.14
import Qt.labs.platform 1.1

import "../basic"

Item {
    property string text: ""
    Label {
        id: downCataLabel
//      textFormat: floderItemRoot.textFormat
        text: qsTr(parent.text)
        anchors.left: parent.left
        color: "white"
        font.pixelSize: 20
        font.family: BasicConfig.commFont
    }
    Label {
        id: cataLabel
        text: qsTr("E:\\git_my_demo\\JtomMusic")
        font.pixelSize: 20
        font.family: BasicConfig.commFont
        width: 300
        anchors.left: downCataLabel.left
        anchors.top: downCataLabel.bottom
        anchors.topMargin: 20
        color: "white"
        elide: Text.ElideRight
    }
    Rectangle {
        id: openFloderRect
        height: 30
        width: 100
        radius: 15
        anchors.left: cataLabel.right
        anchors.leftMargin: (cataLabel.implicitWidth > 100 ? 100 : cataLabel.implicitWidth)
        anchors.verticalCenter: cataLabel.verticalCenter
        color: "transparent"
        border.width: 1
        border.color: BasicConfig.fieldBgBordColor
        Label {
            text: qsTr("更改目录")
            font.pixelSize: 20
            font.family: BasicConfig.commFont
            anchors.centerIn: parent
            anchors.topMargin: 20
            color: "white"
        }
        MouseArea {
            anchors.fill: parent
            hoverEnabled: true
            onEntered: {
                parent.color = BasicConfig.commGray
                cursorShape = Qt.PointingHandCursor
            }
            onExited: {
                parent.color = "transparent"
                cursorShape = Qt.ArrowCursor
            }
            onClicked: {
                folderDialog.open();
            }
        }
    }
    FolderDialog {
        id: folderDialog
        onAccepted: {
            let s = String(folderDialog.currentFolder)
            s = s.slice(8, s.length)
            cataLabel.text = s
            console.log(s)
        }
    }
}

